From 3f4cebeba92e794669f7c901fb53786bee155e5a Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Tue, 11 Jan 2022 08:07:24 -0700 Subject: [PATCH] capture git hash on github action builds. (#816) * capture git hash on github action builds. * modernize version sha display * delete stray space --- gbversion.cmake | 1 + gbversion.h.in | 3 ++- gbversion.h.qmake.in | 3 ++- gbversion.pri | 1 + gui/aboutdlg.cc | 8 +++++++- gui/aboutdlg.h | 3 ++- gui/aboutui.ui | 7 ++++--- gui/mainwindow.cc | 2 +- main.cc | 4 ++++ 9 files changed, 24 insertions(+), 8 deletions(-) diff --git a/gbversion.cmake b/gbversion.cmake index dc6f1a55f..6d64a28c2 100644 --- a/gbversion.cmake +++ b/gbversion.cmake @@ -23,6 +23,7 @@ list(GET VERSION_COMPONENTS 2 GB.MICRO) # A: it's used by win32/gpsbabel.rc which includes gbversion.h set(GB.BUILD 31 CACHE STRING "Fourth component of Windows VERSIONINFO resource FILEVERSION and PRODUCTVERSION parameters.") set(GB.PACKAGE_RELEASE "" CACHE STRING "String to append to VERSION tuple.") # .e.g. "-beta20190413" +set(GB.SHA $ENV{GITHUB_SHA}) # may be overridden on cmake command line set(DOCVERSION ${GB.VERSION} CACHE STRING "String appended to documentation location for www.gpsbabel.org.") diff --git a/gbversion.h.in b/gbversion.h.in index 4778bfb39..b88226a76 100644 --- a/gbversion.h.in +++ b/gbversion.h.in @@ -10,8 +10,9 @@ #define VER_FILE @GB.MAJOR@,@GB.MINOR@,@GB.MICRO@,@GB.BUILD@ #define VER_PRODUCT @GB.MAJOR@,@GB.MINOR@,@GB.MICRO@,@GB.BUILD@ #define VER_FILE_STR "@GB.MAJOR@.@GB.MINOR@.@GB.MICRO@@GB.PACKAGE_RELEASE@" -#define VER_PRODUCT_STR "@GB.MAJOR@.@GB.MINOR@.@GB.MICRO@@GB.PACKAGE_RELEASE@" +#define VER_PRODUCT_STR "@GB.MAJOR@.@GB.MINOR@.@GB.MICRO@@GB.PACKAGE_RELEASE@" #else #define VERSION "@GB.MAJOR@.@GB.MINOR@.@GB.MICRO@@GB.PACKAGE_RELEASE@" +constexpr char kVersionSHA[] = "@GB.SHA@"; #define WEB_DOC_DIR "https://www.gpsbabel.org/htmldoc-@DOCVERSION@" #endif diff --git a/gbversion.h.qmake.in b/gbversion.h.qmake.in index ead3c6199..1b50b9548 100644 --- a/gbversion.h.qmake.in +++ b/gbversion.h.qmake.in @@ -10,8 +10,9 @@ #define VER_FILE $${GB.MAJOR},$${GB.MINOR},$${GB.MICRO},$${GB.BUILD} #define VER_PRODUCT $${GB.MAJOR},$${GB.MINOR},$${GB.MICRO},$${GB.BUILD} #define VER_FILE_STR \"$${GB.MAJOR}.$${GB.MINOR}.$${GB.MICRO}$${GB.PACKAGE_RELEASE}\" -#define VER_PRODUCT_STR \"$${GB.MAJOR}.$${GB.MINOR}.$${GB.MICRO}$${GB.PACKAGE_RELEASE}\" +#define VER_PRODUCT_STR \"$${GB.MAJOR}.$${GB.MINOR}.$${GB.MICRO}$${GB.PACKAGE_RELEASE}\" #else #define VERSION \"$${GB.MAJOR}.$${GB.MINOR}.$${GB.MICRO}$${GB.PACKAGE_RELEASE}\" +constexpr char kVersionSHA[] = \"$${GB.SHA}\"; #define WEB_DOC_DIR \"https://www.gpsbabel.org/htmldoc-$${DOCVERSION}\" #endif diff --git a/gbversion.pri b/gbversion.pri index 9967e9700..f5f74074e 100644 --- a/gbversion.pri +++ b/gbversion.pri @@ -23,6 +23,7 @@ GB.MICRO = $$member(GB.VERSION_COMPONENTS, 2) # A: it's used by win32/gpsbabel.rc which includes gbversion.h GB.BUILD = 31 # GB.PACKAGE_RELEASE = "-beta20190413" +GB.SHA = $$(GITHUB_SHA) # may be overridden on qmake command line !defined(DOCVERSION, var) { diff --git a/gui/aboutdlg.cc b/gui/aboutdlg.cc index 3e92bbe4f..e98427924 100644 --- a/gui/aboutdlg.cc +++ b/gui/aboutdlg.cc @@ -29,7 +29,8 @@ AboutDlg::AboutDlg(QWidget* parent, const QString& ver1, - const QString& ver2, const QString& installationId): QDialog(parent) + const QString& ver2, const QString& ver3, + const QString& installationId): QDialog(parent) { ui_.setupUi(this); QTextDocument* doc = ui_.textEdit->document(); @@ -38,6 +39,11 @@ AboutDlg::AboutDlg(QWidget* parent, const QString& ver1, tt.replace("$appname$", appName); tt.replace("$babelversion$", ver1); tt.replace("$babelfeversion$", ver2); + if (ver3.isEmpty()) { + tt.replace("$hash$", ""); + } else { + tt.replace("$hash$", "Hash: " + ver3); + } tt.replace("$installationId$", installationId); // Not localized as it should never be seen. diff --git a/gui/aboutdlg.h b/gui/aboutdlg.h index a93ac2a6d..d20ca0af8 100644 --- a/gui/aboutdlg.h +++ b/gui/aboutdlg.h @@ -32,7 +32,8 @@ class AboutDlg: public QDialog { public: AboutDlg(QWidget* parent, const QString& ver1, - const QString& ver2, const QString& installationId); + const QString& ver2, const QString& ver3, + const QString& installationId); private: Ui_AboutDlg ui_; diff --git a/gui/aboutui.ui b/gui/aboutui.ui index 48eb2c7d9..bfd741e3d 100644 --- a/gui/aboutui.ui +++ b/gui/aboutui.ui @@ -72,20 +72,21 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:600;">$appname$</span></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:12pt;">$babelfeversion$</span></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:12pt;">Copyright (C) 2009-2016 Robert Lipe</span></p> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:12pt;">GUI designed and contributed by S. Khai Mong</span></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:12pt;">GUI designed and contributed by S. Khai Mong</span></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:12pt;">LGPL Crystal Icons by Elvarado Coehlo</span></p> <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:12pt;"><br /></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:12pt;">(Using backend $babelversion$)</span></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:12pt;">$hash$</span></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:12pt;">$upgradetestmode$</span></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:12pt;">Installation ID: $installationId$</span></p> <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:12pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:12pt;">This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:12pt;">This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:12pt;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:12pt;">This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:12pt;"><br /></p> diff --git a/gui/mainwindow.cc b/gui/mainwindow.cc index d4b153b50..c76fa7f9c 100644 --- a/gui/mainwindow.cc +++ b/gui/mainwindow.cc @@ -1159,7 +1159,7 @@ void MainWindow::moreOptionButtonClicked() //------------------------------------------------------------------------ void MainWindow::aboutActionX() { - AboutDlg aboutDlg(nullptr, babelVersion_, QString(appName) + QString(" " VERSION), babelData_.installationUuid_); + AboutDlg aboutDlg(nullptr, babelVersion_, QString(appName) + QString(" " VERSION), kVersionSHA, babelData_.installationUuid_); aboutDlg.setWindowTitle(tr("About %1").arg(appName)); aboutDlg.exec(); } diff --git a/main.cc b/main.cc index c3d2aa490..70d277d2c 100644 --- a/main.cc +++ b/main.cc @@ -48,6 +48,7 @@ #include "filter.h" // for Filter #include "filter_vecs.h" // for FilterVecs #include "format.h" // for Format +#include "gbversion.h" // for VERSION_SHA #include "inifile.h" // for inifile_done, inifile_init #include "session.h" // for start_session, session_exit, session_init #include "src/core/datetime.h" // for DateTime @@ -432,6 +433,9 @@ run(const char* prog_name) */ if (global_opts.debug_level > 0) { warning("GPSBabel Version: %s\n", gpsbabel_version); + if(sizeof(kVersionSHA) > 1) { + warning(MYNAME ": Repository SHA: %s\n", kVersionSHA); + } warning(MYNAME ": Compiled with Qt %s for architecture %s\n", QT_VERSION_STR, qPrintable(QSysInfo::buildAbi())); -- 2.30.2